package com.shu.driftbook.action;

import com.opensymphony.xwork2.ActionSupport;
import com.shu.driftbook.dao.Book;
import com.shu.driftbook.dao.DriftQueue;
import com.shu.driftbook.service.BookService;
import com.shu.driftbook.service.UserService;

import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
public class bookDetail extends ActionSupport {
	private BookService service;
	private String isbn;
	public String execute() throws Exception {
		List<Book> book = null;
		Book book1;
		book=service.find2(isbn);
		int j=0;
		String k="0";
		for (Iterator i = book.iterator(); i.hasNext();) {
			book1=(Book) i.next();
			if(book1.getStatement()==0){
				k="1";
				break;
			}
			else {
				j++;
			}
		}	
		if(k=="0"){j--;}
		service.find3(book.get(j).getBookname());
		HttpServletRequest request=ServletActionContext.getRequest();
		request.setAttribute("bookname", book.get(j).getBookname());
		request.setAttribute("author",book.get(j).getAuthor());
		request.setAttribute("publisher", book.get(j).getPublisher());
		request.setAttribute("picture", book.get(j).getCover());
		request.setAttribute("about",book.get(j).getAbout());
		request.setAttribute("whether", k);
		return "SUCCESS";
	}
	
	public BookService getService() {
		return service;
	}

	public void setService(BookService service) {
		this.service = service;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

}
